import java.util.Arrays;
import java.util.Scanner;

public class Class3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i=0;i<n;i++){
            nums[i] = scanner.nextInt();
        }
        Arrays.sort(nums);
        //先找出第一个大于0的数
        int start = Integer.MAX_VALUE;
        for (int i=0;i<nums.length;i++){
            if (nums[i]>0)
                start = i;
        }
        if (start==Integer.MAX_VALUE){
            System.out.println(0);
            return;
        }
        int max_val =0;
        for (int i=start;i<nums.length;i++){
            max_val += nums[start];
        }
        if (max_val%7==0){
            System.out.println(max_val);
            return;
        }


    }
}
